/**
 * $Id: ReciverDeliverConnDeamon.java,v 1.3 2006/09/13 05:40:38 martin Exp $
 *
 * Copyright 2006 Skyinfo, Inc. All Rights Reserved.
 */
package com.haoxi.gateway.runner;

import java.util.List;

import com.haoxi.gateway.common.InitGatewayConfig;
import com.haoxi.gateway.common.Queue;
import com.haoxi.gateway.connector.Connector;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
 * 依据连接建立所有可监听的ReciverThread
 * 
 * Revision History
 * 
 * 2006-6-12,star.Zhao,created it
 */
public class ReciverDeliverConnDeamon extends AbsConnectorDaemon {
    private static final Log log = LogFactory.getLog(ReciverDeliverConnDeamon.class);
    /**
     * 
     */
    private List connectors;

    /**
     * 
     */
    private Queue queue;

    /**
     * @param connectors
     * @param queue
     */
    public ReciverDeliverConnDeamon(List connectors, Queue queue) {
        this.name = "ReciverDeliverConnDeamon";
        this.queue = queue;
        this.connectors = connectors;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.haoxi.gateway.runner.AbsConnectorDaemon#getThreads()
     */
    public IRun[] getThreads() {
        
        int length = this.connectors.size();
        setCurrentReciveConnCount(length);
        IRun[] threads = new IRun[length];
        String gatWaycode = InitGatewayConfig.getInstance().getGatewayInfo()
                .getGatewayCode();
        for (int i = 0; i < length; i++) {
            
            Connector connector = (Connector) this.connectors.get(i);
            threads[i] = new ReciverDeliverThread(connector, this.queue);
        }
        return threads;
    }

}
